package com.aplink.dellcommercial.database.sharepreference;

import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

import com.aplink.dellcommercial.constant.Constant;

import static com.aplink.dellcommercial.configuration.DellController.getInstance;

public class CustomerSharePreferenceHelper {
    public static boolean getBoolean( String key ) {
        final SharedPreferences settings = getInstance()
                .getSharedPreferences( Constant.SHAREDPREFERENCE_USERPROFILE, 0 );
        return settings.getBoolean( key, false );
    }

    public static int getInt( String key ) {
        final SharedPreferences settings = getInstance()
                .getSharedPreferences( Constant.SHAREDPREFERENCE_USERPROFILE, 0 );
        return settings.getInt( key, 0 );
    }

    public static String getString( String key ) {
        final SharedPreferences settings = getInstance()
                .getSharedPreferences( Constant.SHAREDPREFERENCE_USERPROFILE, 0 );
        return settings.getString( key, null );
    }

    public static boolean storeBoolean( String key, boolean value ) {
        final Editor editor = getInstance()
                .getApplicationContext()
                .getSharedPreferences( Constant.SHAREDPREFERENCE_USERPROFILE, 0 )
                .edit();
        editor.putBoolean( key, value );
        return editor.commit();
    }

    public static boolean storeInt( String key, int value ) {
        final Editor editor = getInstance()
                .getApplicationContext()
                .getSharedPreferences( Constant.SHAREDPREFERENCE_USERPROFILE, 0 )
                .edit();
        editor.putInt( key, value );
        return editor.commit();
    }

    public static boolean storeString( String key, String value ) {
        final Editor editor = getInstance()
                .getApplicationContext()
                .getSharedPreferences( Constant.SHAREDPREFERENCE_USERPROFILE, 0 )
                .edit();
        editor.putString( key, value );
        return editor.commit();
    }
}
